package com.xintonghua.bussiness.adapter;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.xintonghua.bussiness.R;
import com.xintonghua.bussiness.base.SimpleBaseAdapter;
import com.xintonghua.bussiness.bean.ConsumptionBean;

import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * 作者：wanxianyi
 * 时间：2018/4/25.
 * 包名：com.xintonghua.bussiness.adapter
 */

public class ConsumptionAdapter extends SimpleBaseAdapter<ConsumptionBean> {


    public ConsumptionAdapter(List<ConsumptionBean> list, Context context) {
        super(list, context);
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ConsumptionViewHolder holder;
        if (convertView == null) {
            convertView = mInflater.inflate(R.layout.adapter_consumption, parent, false);
            holder = new ConsumptionViewHolder(convertView);
            convertView.setTag(holder);
        } else {
            holder = (ConsumptionViewHolder) convertView.getTag();
        }
        ConsumptionBean bean = mList.get(position);
        holder.tvFriend.setText(bean.getResource());
        holder.tvPengyoujieshao.setText(bean.getTotal() + "元");
        return convertView;
    }

    public static class ConsumptionViewHolder {
        @BindView(R.id.iv_friend)
        ImageView ivFriend;
        @BindView(R.id.tv_friend)
        TextView tvFriend;
        @BindView(R.id.tv_pengyoujieshao)
        TextView tvPengyoujieshao;

        public ConsumptionViewHolder(View view) {
            ButterKnife.bind(this, view);
        }
    }
}
